/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class PromotionItemApplicability
    {
    
        private String ASINField;

        private Boolean? isInBenefitSetField;

        private Boolean? isInEligibilityRequirementSetField;


        /// <summary>
        /// Gets and sets the ASIN property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ASIN")]
        public String ASIN
        {
            get { return this.ASINField ; }
            set { this.ASINField= value; }
        }



        /// <summary>
        /// Sets the ASIN property
        /// </summary>
        /// <param name="ASIN">ASIN property</param>
        /// <returns>this instance</returns>
        public PromotionItemApplicability WithASIN(String ASIN)
        {
            this.ASINField = ASIN;
            return this;
        }



        /// <summary>
        /// Checks if ASIN property is set
        /// </summary>
        /// <returns>true if ASIN property is set</returns>
        public Boolean IsSetASIN()
        {
            return  this.ASINField != null;

        }


        /// <summary>
        /// Gets and sets the IsInBenefitSet property.
        /// </summary>
        [XmlElementAttribute(ElementName = "IsInBenefitSet")]
        public Boolean IsInBenefitSet
        {
            get { return this.isInBenefitSetField.GetValueOrDefault() ; }
            set { this.isInBenefitSetField= value; }
        }



        /// <summary>
        /// Sets the IsInBenefitSet property
        /// </summary>
        /// <param name="isInBenefitSet">IsInBenefitSet property</param>
        /// <returns>this instance</returns>
        public PromotionItemApplicability WithIsInBenefitSet(Boolean isInBenefitSet)
        {
            this.isInBenefitSetField = isInBenefitSet;
            return this;
        }



        /// <summary>
        /// Checks if IsInBenefitSet property is set
        /// </summary>
        /// <returns>true if IsInBenefitSet property is set</returns>
        public Boolean IsSetIsInBenefitSet()
        {
            return  this.isInBenefitSetField != null;

        }


        /// <summary>
        /// Gets and sets the IsInEligibilityRequirementSet property.
        /// </summary>
        [XmlElementAttribute(ElementName = "IsInEligibilityRequirementSet")]
        public Boolean IsInEligibilityRequirementSet
        {
            get { return this.isInEligibilityRequirementSetField.GetValueOrDefault() ; }
            set { this.isInEligibilityRequirementSetField= value; }
        }



        /// <summary>
        /// Sets the IsInEligibilityRequirementSet property
        /// </summary>
        /// <param name="isInEligibilityRequirementSet">IsInEligibilityRequirementSet property</param>
        /// <returns>this instance</returns>
        public PromotionItemApplicability WithIsInEligibilityRequirementSet(Boolean isInEligibilityRequirementSet)
        {
            this.isInEligibilityRequirementSetField = isInEligibilityRequirementSet;
            return this;
        }



        /// <summary>
        /// Checks if IsInEligibilityRequirementSet property is set
        /// </summary>
        /// <returns>true if IsInEligibilityRequirementSet property is set</returns>
        public Boolean IsSetIsInEligibilityRequirementSet()
        {
            return  this.isInEligibilityRequirementSetField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetASIN()) {
                xml.Append("<ASIN>");
                xml.Append(EscapeXML(this.ASIN));
                xml.Append("</ASIN>");
            }
            if (IsSetIsInBenefitSet()) {
                xml.Append("<IsInBenefitSet>");
                xml.Append(this.IsInBenefitSet);
                xml.Append("</IsInBenefitSet>");
            }
            if (IsSetIsInEligibilityRequirementSet()) {
                xml.Append("<IsInEligibilityRequirementSet>");
                xml.Append(this.IsInEligibilityRequirementSet);
                xml.Append("</IsInEligibilityRequirementSet>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}